how to use event in javascript